function Car(brand, color, replacement) {
    this.brand = brand;
    this.color = color;
    this.replacement = replacement
    this.info = function () {
        return "品牌为" + this.brand + "颜色为" + this.color + "排量为" + this.replacement
    }
}

function Person(opt) {
    // 用Apply改变this指向,将对应属性设置到person实例
    Car.apply(this, [opt.brand, opt.color, opt.replacement]);
    this.name = opt.name
    this.age = opt.age
    this.say = function () {
        console.log(this.age + "岁的" + this.name + "买了一辆" + this.info() + "的车");

    }

}
var p = new Person({
    name: "张三",
    age: 18,
    brand: "奔驰",
    color: "红色",
    replacement: "2.0L"

})
var str = Object.prototype.toString;
if (str.call(p) === '[Function: Person]') {
    console.log("是构造函数");
} else
    console.log('不是构造函数');
console.log(str.call(p));
console.log(p instanceof Person);




function sum(n) {
    if (n <= 1) {
        return 1;
    }
    return n + sum(n - 1);
}
var sum = (function (n) {
    if (n <= 1) {
        return 1;
    }
    return n + arguments.callee(n - 1);
})(100);
console.log(sum);


